import { _decorator, Component, Node, RigidBody2D, v2, Contact2DType, Collider2D } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('fly')
export class fly extends Component {
	
    start() {
        let collider = this.getComponent(Collider2D);
        if (collider) {
            collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
        }

    }
	fly(){
		this.node.getComponent(RigidBody2D).linearVelocity = v2(0,8)
	}
    onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
        // 只在两个碰撞体开始接触时被调用一次
        if(otherCollider.tag===4){
            console.debug('输了')
        }
         if(otherCollider.tag===3){
            console.debug('加分')
        }
    }
    update(deltaTime: number) {
        
    }
}

